<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	 <meta charset="UTF-8">
	 <title th:replace="common/base::pagetitle"></title>
	 <link th:replace="common/base::static"/>
</head>
<body>
<div class="layui-form" style="padding: 20px 30px 0 0;">
	 <div class="layui-form-item"  th:each="bank,userStat : ${list}">
		  <div class="layui-input-inline" id="bankSelectId">
				<label><input type="radio" lay-verify="orderReq"  name="bank" th:value="${bank.id}">
				
				</label>
				银行名称： <span  th:text="${bank.compName}"></span>
				
<!--				<input type="radio" name="bankId" th:value="${bank.id}" lay-verify="required" autocomplete="off" class="layui-input">-->
<!--				${bank.compName}-->
		  </div>
	 </div>
	 <!--<div class="layui-form-item">
		  <label class="layui-form-label">发布状态</label>
		  <div class="layui-input-inline">
				<input type="checkbox" lay-verify="required" lay-filter="status" name="status" lay-skin="switch" lay-text="已发布|待修改"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>待修改</em><i></i></div>
		  </div>
	 </div>-->
	 <div class="layui-form-item layui-hide">
<!--		  <input type="text" id="tradeId" name="tradeId"  th:value="${tradeId}" placeholder="保存ID" autocomplete="off" class="layui-input">-->
		  <input type="button" lay-submit="" lay-filter="kFormSubmit" id="kFormSubmit" value="确认添加">
		 
		  <input type="button" lay-submit="" lay-filter="kFormVoucherView" id="kFormVoucherView" value="凭证预览">
		  <!--        <input type="text" name="deptId" th:value="${editInfo.deptId}" placeholder="保存deptId" autocomplete="off" class="layui-input">-->
	 </div>
</div>

<script th:replace="common/base::context"></script>
<script th:replace="common/base::mainjs"></script>
<script th:src="@{/static/js/select-tree.js}"></script>
<script>
    layui.use(['form'], function () {
        var $ = layui.$, form = layui.form, layer = layui.layer, table = layui.table;
		// 表单校验
        form.verify({
            orderReq: function(value,item){
                var $ = layui.$;
                var verifyName=$(item).attr('name')
                    , verifyType=$(item).attr('type')
                    ,formElem=$(item).parents('.layui-form')//获取当前所在的form元素，如果存在的话
                    ,verifyElem=formElem.find('input[name='+verifyName+']')//获取需要校验的元素
                    ,isTrue= verifyElem.is(':checked')//是否命中校验
                    ,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
                if(!isTrue || !value){
                    //定位焦点
                    focusElem.css(verifyType=='radio'?{"color":"#FF5722"}:{"border-color":"#FF5722"});
                    //对非输入框设置焦点
                    focusElem.first().attr("tabIndex","1").css("outline","0").blur(function() {
                        focusElem.css(verifyType=='radio'?{"color":""}:{"border-color":""});
                    }).focus();
                    return '必填项不能为空';
                }
            }
        });

        //监听提交
        form.on('submit(kFormSubmit)', function (data) {
            var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.open({
						  type: 2
						  , title: '生成凭证'
						  , content: BASE_WEB + 'voucher/generate/preview' + '?id=' + field.tradeId + '&bankId='+ field.bank
						  , maxmin: true
						  , area: ['80%', '60%']   // 宽高
						  , btn: ['生成', '取消']
						  , yes: function (index, layero) {
								//点击确认触发 iframe 内容中的按钮提交
								var submit = layero.find('iframe').contents().find("#kFormSubmit");
								submit.click();
						  }
						  // , btn2: function (index, layero) {
							// 	//点击确认触发 iframe 内容中的按钮提交
							// 	var check = layero.find('iframe').contents().find("#kFormCheck");
							// 	check.click();
							// 	return false;
						  // }
				});
        });
    })
</script>
</body>
</html>